﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Gateway;
namespace Web.netPost
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {

            //按时构造订单号；

            System.DateTime currentTime = new System.DateTime();
            currentTime = System.DateTime.Now;
            string out_trade_no = currentTime.ToString("g");
            out_trade_no = out_trade_no.Replace("-", "");
            out_trade_no = out_trade_no.Replace(":", "");
            out_trade_no = out_trade_no.Replace(" ", "");
            //业务参数赋值；
            string gateway = T_gateway.Text;	//'支付接口
            string service = T_service.Text;
            string partner = "2088002136145985";		//partner		合作伙伴ID			保留字段
            string sign_type = T_sign_type.Text;
            string subject = T_subject.Text;	//subject		商品名称
            string body = T_body.Text;		//body			商品描述    
            string payment_type = T_payment_type.Text;                  //支付类型	
            string price = T_total_fee.Text;
            string quantity = TextBox1.Text;
            string show_url = T_show_url.Text;
            string seller_email = T_seller_email.Text;             //卖家账号
            string key = "hpls98hfsur47l0y8cda66pyu5pvsbz7";              //partner账户的支付宝安全校验码
            string return_url = T_return_url.Text; //服务器通知返回接口
            string notify_url = T_notify_url.Text; //服务器通知返回接口
            string _input_charset = T_inputchatset.Text;
            string logistics_type = "POST";
            string logistics_fee = TextBox2.Text;
            string logistics_payment = "BUYER_PAY";
            string logistics_type_1 = "EXPRESS";
            string logistics_fee_1 = TextBox3.Text;
            string logistics_payment_1 = "BUYER_PAY";
            AliPay ap = new AliPay();
            string aliay_url = ap.CreatUrl(
                gateway,
                service,
                partner,
                sign_type,
                out_trade_no,
                subject,
                body,
                payment_type,
                price,
                show_url,
                seller_email,
                key,
                return_url,
                _input_charset,
                notify_url,
                logistics_type,
                logistics_fee,
                logistics_payment,
                logistics_type_1,
                logistics_fee_1,
                logistics_payment_1,
                quantity
                );

            Response.Redirect(aliay_url);

        }

    }
}
